package org.eduapp.trains.service.train;

import java.util.List;

import org.eduapp.trains.ServiceException;
import org.eduapp.trains.model.train.ModelTrain;
import org.eduapp.trains.vo.VoTrainSearch;
import org.eduapp.trains.web.support.PaginationSupport;

/**
 * 
 * @author jeccy
 *
 */
public interface TrainService {
	
	/**
	 * get train by given id
	 * @param id
	 * @throws ServiceException
	 */
	ModelTrain get (String id) throws ServiceException;
	
	/**
	 * get train by given train number
	 * @param no
	 * @throws ServiceException
	 */
	ModelTrain getByTrainNo (String no) throws ServiceException;
	
	/**
	 * get trains by train search value object
	 * @param vo
	 * @return
	 * @throws ServiceException
	 */
	PaginationSupport<ModelTrain> getBySearchVO (VoTrainSearch vo) throws ServiceException;
	
	/**
	 * get all trains
	 * @return
	 * @throws ServiceException
	 */
	List<ModelTrain> getAll () throws ServiceException;
	
	/**
	 * get trains to be updated
	 * @return
	 * @throws ServiceException
	 */
	List<ModelTrain> getTrainToBeUpdated() throws ServiceException;
	
	/**
	 * get train pager by train station name
	 * @param stationName
	 * @return
	 * @throws ServiceException
	 */
	PaginationSupport<ModelTrain> getByStations (String stationName) throws ServiceException;
	
	/**
	 * get train pager by train station name
	 * @param stationName
	 * @param offset
	 * @param pageSize
	 * @param order
	 * @param isDesc
	 * @return
	 * @throws ServiceException
	 */
	PaginationSupport<ModelTrain> getByStations (String stationName, int offset, int pageSize, String order, Boolean isDesc) throws ServiceException;
	
	/**
	 * get train pager by train station departure and station arrival
	 * @param stationSrc
	 * @param stationDst
	 * @return
	 * @throws ServiceException
	 */
	PaginationSupport<ModelTrain> getByStation2Station (String stationSrc, String stationDst) throws ServiceException;
	
	/**
	 * get train pager by train station departure and station arrival
	 * @param stationSrc
	 * @param stationDst
	 * @param pageSize
	 * @param order
	 * @param isDesc
	 * @return
	 * @throws ServiceException
	 */
	PaginationSupport<ModelTrain> getByStation2Station (String stationSrc, String stationDst, int offset, int pageSize, String order, Boolean isDesc) throws ServiceException;
	
	/**
	 * 
	 * @param stationSrc
	 * @param stationDst
	 * @param offset
	 * @param pageSize
	 * @param order
	 * @param isDesc
	 * @param vo
	 * @return
	 * @throws ServiceException
	 */
	PaginationSupport<ModelTrain> getByStation2Station (String stationSrc, String stationDst, int offset, int pageSize, String order, Boolean isDesc, VoTrainSearch vo) throws ServiceException;

	/**
	 * save or update train by given model
	 * @param model
	 * @throws ServiceException
	 */
	void saveOrUpdate (ModelTrain model) throws ServiceException;
	
	/**
	 * remove train by given id
	 * @param id
	 * @throws ServiceException
	 */
	void remove (String id) throws ServiceException;
	
	/**
	 * remove train by given model
	 * @param model
	 * @throws ServiceException
	 */
	void remove (ModelTrain model) throws ServiceException;
	
}
